/*
 * @Author: 陈伟 chenwei@duoliheng.com
 * @Date: 2022-07-13 10:56:14
 * @LastEditors: 陈伟 chenwei@duoliheng.com
 * @LastEditTime: 2022-10-26 18:18:16
 * @FilePath: \cool.front\src\main.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/utils/elementuiFix' // 覆盖一些element-ui的设定和修复一些bug
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css
import '@/styles/common.scss' // global common

import App from './App'
import store from './store'
import router from './router'
import { addClass } from '@/utils/className'

import '@/icons' // icon
import '@/permission' // permission control
import '@/common'
import Vant from 'vant'
import 'vant/lib/index.css'
import loadingPlugin from 'v-loading-plugin'
import ElTreeSelect from '@/components/ELTreeSelect'
import ElMenu from '@/components/ElMenu/index.js'
import LbTable from '@/components/LbTable'
import ElTableForm from '@/components/ELTableForm'
import ElInputGroup from '@/components/ElInputGroup'
import FuPage from '@/components/FuPage'

import adaptive from '@/directive/el-height-adaptive-table/index.js'
import elTableInfiniteScroll from '@/directive/el-table-infinite-scroll/index.js'
import drag from '@/directive/el-drag-dialog'
import permission from '@/directive/permission'
import getCachedPageByName from '@/utils/getCachedPageByName'
import BaiduMap from 'vue-baidu-map'
import moment from 'dayjs'
import dayjs from 'dayjs'
import updateLocale from 'dayjs/plugin/updateLocale'
import vcolorpicker from 'vcolorpicker'
import { hasTabPermission } from '@/utils/tabPermission'
import utc from 'dayjs/plugin/utc'
dayjs.extend(utc)

moment.extend(updateLocale)
moment.updateLocale('en', {
  weekStart: 1
})
Vue.use(Vant)
Vue.use(vcolorpicker) // 颜色选择器
Vue.use(loadingPlugin)
Vue.use(ElTreeSelect)
Vue.use(LbTable)
Vue.use(ElTableForm)
Vue.use(ElInputGroup)
Vue.use(FuPage)
Vue.use(adaptive)
Vue.use(elTableInfiniteScroll)
Vue.use(drag)
Vue.use(permission)
Vue.prototype.$getCachedPageByName = getCachedPageByName
Vue.prototype.$hasTabPermission = hasTabPermission

// if (process.env.VUE_APP_USE_MOCKXHR === 'true') {
//   const mockXHR = require('./utils/mockXHR').default
//   mockXHR()
// }

Vue.use(ElementUI, {
  size: store.state.settings.size // set element-ui default size
})
window.addEventListener('load', () => {
  addClass(document.body, `PAGE-SIZE-${store.state.settings.size}`)
})

// element-ui 2.13.0版本菜单组件有bug,这里改手动引用2.10.0版本以及部分bug处理
Vue.use(ElMenu)
Vue.use(BaiduMap, {
  // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
  ak: 'zljP8IQr4tGYh2K1b7TKcETgPtZgN5LK'
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  beforeCreate() {
    Vue.prototype.$bus = this // 安装总线
  },
  router,
  store,
  render: h => h(App)
})
